package com.dsh.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsh.mapper.GoodsBrowserLogMapper;
import com.dsh.model.GoodsBrowserLogEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Map;

@Service
public class GoodsBrowserLogService {
    @Autowired
    GoodsBrowserLogMapper goodsBrowserLogMapper;

    public List<GoodsBrowserLogEntity> findGoodsBrowserLog(Map map){
        String lastTime = (String) map.get("lastTime");
        //增量同步
        if (!StringUtils.isEmpty(lastTime)){
            QueryWrapper<GoodsBrowserLogEntity> objectQueryWrapper = new QueryWrapper<>();
            objectQueryWrapper.lambda().ge(GoodsBrowserLogEntity::getLogTime,lastTime);
            return goodsBrowserLogMapper.selectList(objectQueryWrapper);
        }else {
            //全量同步
            return goodsBrowserLogMapper.selectList(Wrappers.emptyWrapper());
        }


    }
}
